package engine.graphics.popup;

import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Graphics;

import engine.graphics.MapCanvasEngine;
import engine.graphics.misc.GraphicsCustomFont;

public final class PopupOK extends Popup {

	public Object object;

	public static final byte POPUP_CITY = 0;

	public static final byte POPUP_TECHNOLOGY = 1;

	private String text;

	public PopupOK(final String textInfo, final Object selectedObject) {
		this.object = selectedObject;
		this.text = textInfo;
	}

	public void show(final int screenX, final int screenY) {
		Graphics graphics = MapCanvasEngine.canvas.graphics;
		super.show(screenX, screenY, graphics);
		graphics.setColor(192, 192, 192);
		graphics.fillRect(this.x + 1, this.y + 15, width - 2, height - 15 - 1);
		GraphicsCustomFont.drawString(graphics, "[X]", this.x + 2, this.y + 3);
		GraphicsCustomFont.drawString(graphics, this.text, this.x + 5, this.y + MARGIN_PANEL_HEIGHT);
		graphics.setColor(255, 0, 0);
		graphics.drawRect(this.x + 1, this.y + 1, MARGIN_PANEL_HEIGHT, 11);
		this.repaint();
	}

	public void keyPressed(final int key) {
		int action = MapCanvasEngine.canvas.getGameAction(key);
		if (action != 0)
			switch (action) {
				case Canvas.FIRE:
					this.hide();
					break;
				default:
					break;
			}
	}

}
